<template>
  <div class="container">
    <div>
      <el-container>
        <!-- 用于存放网站logo -->
        <el-aside width="80%"><img src="../assets/fishery.jpeg" /></el-aside>
        <el-main>
          <el-link type="info" style="margin: 20px" @click="login"
            >登录</el-link
          >
          <a>|</a>
          <el-link type="info" style="margin: 20px" @click="register"
            >注册</el-link
          >
          <!-- 搜索框 -->
          <!-- <div>
            <el-select
              v-model="queryParameter1"
              placeholder="请选择要查询数据的名称"
            >
              <el-option
                v-for="item in fishData"
                :key="item.queryParameter1"
                :label="item.label"
                :value="item.queryParameter1"
              >
                <span style="float: left">{{ item.label }}</span>
              </el-option>
            </el-select>
          </div> -->
          <div style="margin-top: 15px">
            <el-input
              placeholder="请输入内容"
              class="input-with-select"
              v-model="parameterValue1"
            >
              <el-button
                slot="append"
                icon="el-icon-search"
                @click="searchForm"
              ></el-button>
            </el-input>
          </div>
        </el-main>
      </el-container>
    </div>
    <!-- 菜单栏 -->
    <div class="menuBar">
      <el-row :gutter="5">
        <el-col :span="2" :offset="2">
          <el-dropdown>
            <span class="el-dropdown-link">
              下拉菜单<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>选项1</el-dropdown-item>
              <el-dropdown-item>选项2</el-dropdown-item>
              <el-dropdown-item>选项3</el-dropdown-item>
              <el-dropdown-item disabled>选项4</el-dropdown-item>
              <el-dropdown-item divided>选项5</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown></el-col
        >
        <el-col :span="2" :offset="2">
          <el-link :underline="false">无下划线</el-link></el-col
        >
        <el-col :span="2" :offset="2">
          <el-link :underline="false">无下划线</el-link></el-col
        >
        <el-col :span="2" :offset="2">
          <el-link :underline="false">无下划线</el-link></el-col
        >
        <el-col :span="2" :offset="2">
          <el-link :underline="false" @click="dataVisualization"
            >数据可视化</el-link
          ></el-col
        >
      </el-row>
    </div>
    <!-- 图片切换 -->
    <div class="block">
      <span class="demonstration"></span>
      <el-carousel height="150px">
        <el-carousel-item v-for="item in 4" :key="item">
          <h3 class="small">{{ item }}</h3>
        </el-carousel-item>
      </el-carousel>
    </div>
    <!--  -->
    <div>
      <el-tabs type="border-card">
        <el-tab-pane label="资源库1">资源库1</el-tab-pane>
        <el-tab-pane label="资源库2">资源库2</el-tab-pane>
        <el-tab-pane label="资源库3">资源库3</el-tab-pane>
        <el-tab-pane label="资源库4">资源库4</el-tab-pane>
      </el-tabs>
    </div>
    <el-footer> 底部信息 </el-footer>
  </div>
</template>

<script>
import Cookies from "js-cookie";
//组件中使用数据用函数
export default {
  data() {
    return {
      // fishData: [
      //   {
      //     queryParameter1: "chineseName",
      //     label: "中文名",
      //   },
      //   {
      //     queryParameter1: "classificationId",
      //     label: "生物学分类编号",
      //   },
      //   {
      //     queryParameter1: "queryId",
      //     label: "统一编号",
      //   },
      //   {
      //     queryParameter1: "englishName",
      //     label: "英文名",
      //   },
      // ],
      parameterValue1: "",
      queryParameter1: "",
    };
  },
  methods: {
    login() {
      this.$router.push("/login");
      // console.log(this.parameterValue1.length);
      // var re = /^[/u4E00-/u9FA5]+$/;
    },
    register() {
      this.$router.push("/register");
    },
    dataVisualization() {
      this.$router.push("/bigdata");
    },
    async searchForm() {
      var re = new RegExp("[\u4E00-\u9FA5]+");
      if (re.test(this.parameterValue1)) {
        // console.log("中文");
        this.queryParameter1 = "chineseName";
      } else {
        if (this.parameterValue1.length == 5) {
          this.queryParameter1 = "classificationId";
        } else if (this.parameterValue1.length == 17) {
          this.queryParameter1 = "queryId";
        } else {
          this.queryParameter1 = "englishName";
        }
      }
      // console.log(this.searchValue);
      const { data: res } = await this.$http.get(
        "fishery?" +
          "parameterValue1=" +
          this.parameterValue1 +
          "&queryParameter1=" +
          this.queryParameter1
      );
      // console.log(res.code);
      if (res.code != 200) {
        return this.$message.error("查询失败，没有该值的数据");
      }
      this.$message.success("查询成功！");
      Cookies.set("parameterValue1", this.parameterValue1);
      Cookies.set("queryParameter1", this.queryParameter1);
      this.$router.push("/form");
      // console.log(res.data.records[0]);
      //Cookies.set("fishValue", this.searchValue);
      //this.$router.push("/form");
    },
  },
};
</script>

<style lang="less" scoped>
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.el-tabs {
  text-align: center;
}
.el-select .el-input {
  width: 130px;
}
.input-with-select .el-input-group__prepend {
  background-color: #fff;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>